<template>
	<view>
		<tito class="tito" title="余额" lefticon="left" @clickLeft="clickLeft" />
		<view class="statistics">
			<view class="number-motions">
				<view class="number">
					￥{{nonPresentIncome}}
				</view>
				<view class="motions">
					可提现金额（元）
				</view>
			</view>
			<view class="withdrawal" @click="getrawal">
				提现
			</view>
			<view class="image">
				<image src="../static/bg-yeda.png" mode=""></image>
			</view>
		</view>
		<view class="whole">
			<uni-segmented-control :current="Number(current)" :values="items" @clickItem="onClickItem" styleType="text"
				activeColor="#2590FA"></uni-segmented-control>
		</view>
		<view class="contenList" v-if="accountList.length > 0">
			<view class="conten" v-for="(item,index) in accountList" :key="item.id">
				<view class="text-jf-number">
					<view class="jf">
						{{transactionTypes[item.type]}}
					</view>
					<view :class="item.type == 4 || item.type == 5 || item.type == 6 || item.type == 7 ? 'number' : 'duihuan'">
						{{item.type == 4 || item.type == 5 || item.type == 6 || item.type == 7 ? '+' : '-'}}{{item.money}}
					</view>
				</view>
				<view class="text-time">
					<view class="text">
						{{transactionTypes[item.type]}}
					</view>
					<view class="time">
						{{item.createTime}}
					</view>
				</view>
			</view>
		</view>
		<view class="none" v-else>
			暂无更多
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				items: ['消费明细', '收入', '支出'],
				nonPresentIncome:0,//余额
				current: "0",
				accountList: [],
				page: 1,
				limit: 10,
				transactionTypes:{
				  1: '套餐充值消费',
				  2: '商品购买消费',
				  3: '收益提现',
				  4: '套餐充值收益(分润)',
				  5: '商品购买收益(分润)',
				  6: '商品首充',
				  7: '积分兑换余额'
				}
			};
		},
		onLoad(ope) {
			if(ope.nonPresentIncome){
				this.nonPresentIncome = ope.nonPresentIncome
			}
		},
		onShow() {
			this.accountDetailList()
		},
		onReachBottom() {
			this.page++
			this.accountDetailList()
		},
		methods: {
			//余额明细列表
			async accountDetailList() {
				let data = {
					kind: this.current == 0 ? '' : this.current,
					page: this.page,
					limit: this.limit,
				}
				let res = await this.$request.get("/water-platform-app-api/customer/customer/accountDetailList", data)
				if (res.data.length > 0) {
					this.accountList.push(...res.data)
				} else {
					uni.showToast({
						title: "没有更多了！",
						icon: "none"
					})
				}
			},
			clickLeft() {
				uni.navigateBack()
			},
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
					this.page = 1
					this.accountList = []
					this.accountDetailList()
				}
			},
			//跳转提现
			getrawal() {
				uni.navigateTo({
					url: "/subpackageA/pages/my/withdrawal?nonPresentIncome=" + this.nonPresentIncome
				})
			}
		}
	}
</script>

<style lang="scss">
	.none{
		text-align: center;
		margin-top: 500rpx;
		font-size: 32rpx;
		color: #B1B2B2;
	}
	.statistics {
		height: 208rpx;
		background: linear-gradient(137deg, #25C5FA 0%, #2590FA 100%);
		border-radius: 16rpx;
		margin: 32rpx 30rpx 40rpx;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 32rpx;
		box-sizing: border-box;
		position: relative;

		.image {
			position: absolute;
			top: 0%;
			right: 62rpx;

			image {
				width: 220rpx;
				height: 220rpx;
			}
		}

		.number-motions {
			.number {
				font-weight: 600;
				font-size: 44rpx;
				color: #FFFFFF;
			}

			.motions {
				font-size: 24rpx;
				color: rgba(255, 255, 255, 0.7);
			}
		}

		.withdrawal {
			width: 112rpx;
			height: 50rpx;
			background: #FFFFFF;
			border-radius: 40rpx 40rpx 40rpx 40rpx;
			font-size: 24rpx;
			color: #2590FA;
			text-align: center;
			line-height: 50rpx;
			z-index: 555;
		}
	}

	.statistics:after {
		content: "";
		width: 100%;
		height: 40rpx;
		position: absolute;
		left: 0;
		bottom: -5rpx;
		background: #25C5FA;
		filter: blur(3px);
		/*为了模糊更明显，调高模糊度*/
		z-index: 2;
	}

	.statistics::before {
		content: "";
		position: absolute;
		left: 50%;
		bottom: 10rpx;
		width: 0;
		height: 0;
		transform: translateX(-50%);
		border-left: 35rpx solid transparent;
		border-right: 35rpx solid transparent;
		border-top: 35rpx solid #24A5FA;
		font-size: 0;
		line-height: 0;
		z-index: 3;
	}

	.contenList {
		padding: 0 30rpx;
		box-sizing: border-box;
		margin-top: 48rpx;

		.conten {
			height: 114rpx;

			.text-jf-number {
				display: flex;
				justify-content: space-between;

				.jf {
					font-weight: 600;
					font-size: 28rpx;
					color: #2E3033;
				}

				.number {
					font-weight: 600;
					font-size: 28rpx;
					color: #FA6B05;
				}

				.duihuan {
					color: #2590FA;
				}
			}

			.text-time {
				display: flex;
				margin-top: 16rpx;

				.text {
					font-size: 24rpx;
					color: #B1B2B2;
				}

				.time {
					font-size: 24rpx;
					color: #B1B2B2;
					margin-left: 24rpx;
				}
			}
		}
	}
</style>